package com.homwork;

public class RunTest2 {
    public static void main(String[] args) {
        Tortoise tor = new Tortoise();
        Rabbit rab = new Rabbit();
        new Thread(tor).start();
        new Thread(rab).start();
    }
    }


    class Tortoise implements Runnable{

        @Override
        public void run() {
            for(int i= 1; i<=30; i++){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("乌龟向前跑了一米");
                if(i == 30){
                    System.out.println("乌龟到达终点。。。。。。");
                    break;
                }
                if(i%10==0){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }
            }

        }
    }

    class Rabbit implements Runnable{
        @Override
        public void run() {
            for( int i =1; i<=30; i++){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("兔子跑了一米=====");
                if(i==30){
                    System.out.println("兔子跑到了终点  哈哈======");
                    break;
                }
                if (i % 10 == 0) {
                    try {
                        Thread.sleep(10000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }
    }